package com.aiyan.edu.govern.gateway.admin.config;

import org.springframework.amqp.core.Exchange;
import org.springframework.amqp.core.ExchangeBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * RabbitMQ配置类
 * <p>
 * 创建交换机
 *
 * @author: zqzhou
 * @create: 2019/10/24 21:30
 **/
@Configuration
public class RabbitmqConfig {

    /**
     * 交换机Bean的名称
     */
    public static final String EXCHANGE_GATEWAY_ROUTES_FANOUT = "exchange_gateway_routes_fanout";

    /**
     * 创建交换机，fanout类型
     *
     * @return
     */
    @Bean(EXCHANGE_GATEWAY_ROUTES_FANOUT)
    public Exchange exchange() {
        return ExchangeBuilder.fanoutExchange(EXCHANGE_GATEWAY_ROUTES_FANOUT).durable(true).build();
    }
}
